package com.wm.service.impl;

import java.util.List;

import javax.annotation.Resource;
import com.wm.bean.User;
import com.wm.dao.UserDao;
import com.wm.service.UserService;

public class UserServiceImpl implements UserService {
	@Resource private UserDao userDao;

	public boolean register(User user){
		
		if (checkname(user.getName())) {
			return false;
		}
		userDao.save(user);
		return true;
	}
	public boolean checkname(String name){
		if (userDao.getUserByName(name).size() >0) {
			return true;
		}
		return false;
	}
	public boolean login(User user) {
		System.out.println(user.getName());
		String hql = "from User where password = '"+user.getPassword()+"' and name = '"+user.getName()+"'";
		if (userDao.getUserByHql(hql).size() > 0) {
			return true;
		}
		return false;
	}

}
